--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  10_MarriedCouples_regPrep.log
  log type:  text
 opened on:  16 Apr 2018, 13:39:29

. ***************************************************************************;
. * REGRESSION PREP ;
. ***************************************************************************;
. local beginTime "DateTime: $S_DATE $S_TIME";

. set more off ;

. set linesize 200 ;

. set mem 5g ;
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. cd "$dataDir" ;

. ***************************************************************************;
. * MERGE POLICY MEASURES, AND OTHER CONTROLS;
. ***************************************************************************;
. use cpsAfterTaxsim ;

. * CHILDREN ;
. gen children = min(qualChild,3) ;

. tab children ;

   children |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    583,419       45.99       45.99
          1 |    245,105       19.32       65.32
          2 |    277,222       21.85       87.17
          3 |    162,752       12.83      100.00
------------+-----------------------------------
      Total |  1,268,498      100.00

. * TAX - THESE USE CPS DATA ;
. sort year state children ;

. merge m:1 year state children using simulatedmeasures ;
(note: variable state was byte, now float to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                       188,769
        from master                   188,649  (_merge==1)
        from using                        120  (_merge==2)

    matched                         1,079,849  (_merge==3)
    -----------------------------------------

. drop if _merge == 2;
(120 observations deleted)

. drop _merge children ;

. summ *SIV* ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
fedEICSIV_~s |  1,079,849    212.5249     253.649          0   1004.273
fedRegTaxS~s |  1,079,849    9241.834    2018.375   5553.485   14127.91
ctcSIV_82cps |  1,079,849     161.828     267.781          0   980.3924
amtSIV_82cps |  1,079,849    1.579542    4.005634          0   29.74353
stEICSIV_8~s |  1,079,849    11.57586     41.5497          0   502.1365
-------------+---------------------------------------------------------
stRegTaxSI~s |  1,079,849     2321.51    1395.633          0   6760.588
stCredSIV_~s |  1,079,849    89.69845    195.6165  -20.99712   1416.175
afdcSIV_82~s |  1,079,849    240.6149    692.0031          0   11458.81

. * MERGE THE MANY WAIVER VARIABLES  ;
. sort state ;

. merge m:1 state using afdcwaivers ;

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                         1,268,498  (_merge==3)
    -----------------------------------------

. drop if _merge==2 ;
(0 observations deleted)

. drop _merge ;

. summ afdcwaiver* ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
afdcwaiver~s |    835,309    1995.589    1.083781       1993       1997
afdcwaive~it |    798,145    1997.792    2.362956       1996       2012
afdcwaive~et |    928,582    1995.102    1.264745       1990       1997
afdcwaiver~i |    707,421    1995.167    1.278231       1993       1997
afdcwaiver~v |    828,961    1994.981    1.542235       1990       1997
-------------+---------------------------------------------------------
afdcwaiver~d |    990,778    1993.946    2.244915       1988       1997

. * TRANSFER PROGRAM PARAMETERS FROM UKPRC - NOT SIMULATED;
. sort year state ;

. merge m:1 year state using state_level_variables_from_UKPRC ;

    Result                           # of obs.
    -----------------------------------------
    not matched                        40,623
        from master                    40,623  (_merge==1)
        from using                          0  (_merge==2)

    matched                         1,227,875  (_merge==3)
    -----------------------------------------

. drop if _merge == 2 ;
(0 observations deleted)

. drop _merge ;

. summ state year pop emp unemp unempr gsp afdcmb2 afdcmb3 afdcmb4
>         fsmb1 fsmb2 fsmb3 fsmb4 ssimb eitcmax0 eitcmax1 eitcmax2
>         steitcr steitcref fedminwge stminwge ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
       state |  1,268,498    25.46125    14.69302          1         51
        year |  1,268,498    1996.408    10.28971       1979       2013
         pop |  1,227,875     9307352     9145724     401851   3.83e+07
         emp |  1,227,875     4304959     4151548     170798   1.70e+07
       unemp |  1,227,875    311796.9    360469.1       8163    2267908
-------------+---------------------------------------------------------
      unempr |  1,227,875    6.302059    2.148802        2.3       17.4
         gsp |  1,227,875      321310    410678.6       4856    2202678
     afdcmb2 |  1,227,875    330.3651    133.9634         60        823
     afdcmb3 |  1,227,875    405.8334    159.0248         96        925
     afdcmb4 |  1,227,875    477.0403    183.4946        120       1028
-------------+---------------------------------------------------------
       fsmb1 |  1,227,875    125.9817    42.23877         63        319
       fsmb2 |  1,227,875    231.2375    77.54116        115        585
       fsmb3 |  1,227,875    331.3988    111.1102        165        839
       fsmb4 |  1,227,875    420.9377    141.0768        209       1065
       ssimb |  1,227,875    483.4195     183.857          0       1036
-------------+---------------------------------------------------------
    eitcmax0 |  1,227,875    239.5539    198.2194          0        487
    eitcmax1 |  1,227,875    1907.007    971.4408        500       3250
    eitcmax2 |  1,227,875    2923.817    1816.166        500       5372
     steitcr |  1,227,875    .0920847    2.521163          0        110
   steitcref |  1,227,875    .1503313     .357396          0          1
-------------+---------------------------------------------------------
   fedminwge |  1,227,875    4.851566    1.339423        3.1       7.25
    stminwge |  1,227,875    4.878823    1.656803       1.25       9.19

. * MERGE ON FEDERAL POVERTY LINE ;
. *gen othersandchildren = min(famsize , 9);
. gen qualchild = min(qualChild , 8) ;

. gen othersandchildren = 2+qualchild;

. sort year othersandchildren qualchild ;

. merge m:1 year othersandchildren qualchild using FPL ;

    Result                           # of obs.
    -----------------------------------------
    not matched                        42,559
        from master                    41,301  (_merge==1)
        from using                      1,258  (_merge==2)

    matched                         1,227,197  (_merge==3)
    -----------------------------------------

. drop if _merge ==2 ;
(1,258 observations deleted)

. drop _merge ;

. summ fpl if year == 1993 & othersandchildren==2 & qualchild == 1 ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
         fpl |          0

. replace fpl = 9960 if year == 1993 & othersandchildren==2 & qualchild == 1 ;
(0 real changes made)

. summ fpl if year == 1993 & othersandchildren==5 & qualchild == 3 ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
         fpl |      2,808       17254           0      17254      17254

. replace fpl = 17245 if year == 1993 & othersandchildren==5 & qualchild == 3 ;
(2,808 real changes made)

. summ fpl ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
         fpl |  1,227,197     13606.7    5200.361       5514      46842

. drop qualchild ;

.  * MERGE IN HOUSING SUBSIDY - 1984 onward;
. replace year = year +1 ;
(1,268,498 real changes made)

. gen pernum = wife_pernum ;

. sort year serial pernum ;

. merge 1:1 year serial pernum using housing_sub_cps ;

    Result                           # of obs.
    -----------------------------------------
    not matched                     4,594,797
        from master                   188,649  (_merge==1)
        from using                  4,406,148  (_merge==2)

    matched                         1,079,849  (_merge==3)
    -----------------------------------------

. drop if _merge == 2;
(4,406,148 observations deleted)

. drop _merge pernum ;

. replace year = year - 1 ;
(1,268,498 real changes made)

. gen houssub = f_houssub*12 ;
(188,649 missing values generated)

. gen schlunch = f_mv_sl ;
(188,649 missing values generated)

. summ f_houssub houssub;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
   f_houssub |  1,079,849    1.859615    18.32508          0        600
     houssub |  1,079,849    22.31538     219.901          0       7200

. * ADJUST VARIABLES THAT NEED IT FOR INFLATION. SOME ARE ALAREDAY DONE ;
. foreach dollar of varlist gsp afdcmb2 afdcmb3 afdcmb4
>                 fsmb1 fsmb2 fsmb3 fsmb4 ssimb eitcmax0 eitcmax1 eitcmax2
>                 fedminwge stminwge fpl houssub schlunch {;
  2.         qui replace `dollar' = `dollar' * (232.957/cpi);
  3.         };

. ***************************************************************************;
. * MAKING VARIABLES ;
. ***************************************************************************;
. gen afdcmb = 0 ;

. replace afdcmb = afdcmb2 if qualChild == 1 ;
(245,105 real changes made, 7,975 to missing)

. replace afdcmb = afdcmb3 if qualChild == 2 ;
(277,222 real changes made, 8,136 to missing)

. replace afdcmb = afdcmb4 if qualChild >= 3 ;
(162,752 real changes made, 5,648 to missing)

. gen fsmb = 0 ;

. replace fsmb = fsmb1 if qualChild == 0 ;
(583,419 real changes made, 18,864 to missing)

. replace fsmb = fsmb2 if qualChild == 1 ;
(245,105 real changes made, 7,975 to missing)

. replace fsmb = fsmb3 if qualChild == 2 ;
(277,222 real changes made, 8,136 to missing)

. replace fsmb = fsmb4 if qualChild >= 3 ;
(162,752 real changes made, 5,648 to missing)

. gen minwage = fedminwge+stminwge ;
(40,623 missing values generated)

. *replace famsize = min(famsize,5) ;
. replace hhsize = min(hhsize-1-qualChild, 5)  ;
(1,268,498 real changes made)

. sort state year;

. by state year: gen oneobs = _n ;

. summ afdcmb3 if oneobs == 1 & year==1984, d ;

                           afdcmb3
-------------------------------------------------------------
      Percentiles      Smallest
 1%     215.2442       215.2442
 5%     284.7501        264.571
10%     367.7088       284.7501       Obs                  51
25%     517.9313        318.382       Sum of Wgt.          51

50%     719.7228                      Mean           722.4045
                        Largest       Std. Dev.      280.7619
75%     825.1027       1179.359
90%     1121.063       1186.085       Variance       78827.26
95%     1186.085       1188.327       Skewness       .5034909
99%      1560.52        1560.52       Kurtosis       3.238699

. gen temp = afdcmb3>r(mean) if year==1984;
(1,232,886 missing values generated)

. sort state;

. by state : egen afdcmb3GTmean = max(temp);

. tab afdcmb3GTmean ;

afdcmb3GTme |
         an |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    603,484       47.57       47.57
          1 |    665,014       52.43      100.00
------------+-----------------------------------
      Total |  1,268,498      100.00

. drop oneobs temp;

. foreach var in jobs limit asset medi prov child {;
  2.         gen byte wave_`var' = (year>=afdcwaiver`var');
  3.         replace wave_`var' = 0 if wave_`var'==. ;
  4.         gen byte waveXc_`var' = (wave_`var')*(qualChild>0) ;
  5.         };
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)

. gen byte anywave = (wave_jobs+wave_limit+wave_asset+wave_medi+wave_prov+wave_child)>0 ;

. gen byte anywaveXc = anywave*(qualChild>0) ;

. summ afdcwaiver* wave_* waveXc_* anywave anywaveXc;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
afdcwaiver~s |    835,309    1995.589    1.083781       1993       1997
afdcwaive~it |    798,145    1997.792    2.362956       1996       2012
afdcwaive~et |    928,582    1995.102    1.264745       1990       1997
afdcwaiver~i |    707,421    1995.167    1.278231       1993       1997
afdcwaiver~v |    828,961    1994.981    1.542235       1990       1997
-------------+---------------------------------------------------------
afdcwaiver~d |    990,778    1993.946    2.244915       1988       1997
   wave_jobs |  1,268,498    .3628512    .4808226          0          1
  wave_limit |  1,268,498    .3127045    .4635952          0          1
  wave_asset |  1,268,498    .4161985    .4929275          0          1
   wave_medi |  1,268,498    .3216733    .4671186          0          1
-------------+---------------------------------------------------------
   wave_prov |  1,268,498    .3681661     .482307          0          1
  wave_child |  1,268,498    .4640378    .4987052          0          1
 waveXc_jobs |  1,268,498    .2035628    .4026476          0          1
waveXc_limit |  1,268,498    .1754256    .3803309          0          1
waveXc_asset |  1,268,498    .2316464    .4218844          0          1
-------------+---------------------------------------------------------
 waveXc_medi |  1,268,498    .1815438    .3854683          0          1
 waveXc_prov |  1,268,498    .2048628    .4036015          0          1
waveXc_child |  1,268,498    .2580643    .4375697          0          1
     anywave |  1,268,498    .5203745    .4995849          0          1
   anywaveXc |  1,268,498    .2888566    .4532313          0          1

. egen minyear = rowmin(afdcwaiver*) ;
(154356 missing values generated)

. gen waiver1995 = 0 ;

. replace waiver1995 = 1 if minyear < 1995 & minyear!=. & minyear!=0;
(611,711 real changes made)

. tab waiver1995, missing;

 waiver1995 |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    656,787       51.78       51.78
          1 |    611,711       48.22      100.00
------------+-----------------------------------
      Total |  1,268,498      100.00

. drop minyear ;

. foreach i in H W {;
  2.         foreach a of numlist 20(4)52 {;
  3.                 gen byte age`i'_`a' = (age`i' >= `a' & age`i' <= `a'+3);
  4.                 };
  5.                 summ age`i' age`i'_* ;
  6.                 };

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
        ageH |  1,268,498     47.8961    15.11052          0         99
     ageH_20 |  1,268,498     .017598     .131485          0          1
     ageH_24 |  1,268,498    .0495775    .2170706          0          1
     ageH_28 |  1,268,498    .0779055     .268023          0          1
     ageH_32 |  1,268,498     .093997    .2918247          0          1
-------------+---------------------------------------------------------
     ageH_36 |  1,268,498    .0992095    .2989432          0          1
     ageH_40 |  1,268,498    .0995816    .2994414          0          1
     ageH_44 |  1,268,498    .0938109    .2915656          0          1
     ageH_48 |  1,268,498    .0863478     .280877          0          1
     ageH_52 |  1,268,498     .076835    .2663295          0          1

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
        ageW |  1,268,498    45.35006    14.71453          0         99
     ageW_20 |  1,268,498    .0318006    .1754689          0          1
     ageW_24 |  1,268,498    .0658409    .2480038          0          1
     ageW_28 |  1,268,498    .0908571    .2874058          0          1
     ageW_32 |  1,268,498    .1021216    .3028082          0          1
-------------+---------------------------------------------------------
     ageW_36 |  1,268,498    .1034633    .3045632          0          1
     ageW_40 |  1,268,498    .1014207    .3018851          0          1
     ageW_44 |  1,268,498    .0930258    .2904687          0          1
     ageW_48 |  1,268,498    .0830147    .2759046          0          1
     ageW_52 |  1,268,498    .0718803    .2582897          0          1

. foreach i in H W {;
  2.         gen byte hgc`i'_11 = (hgc`i' < 12) ;
  3.         foreach e in 12 13 16 17 {;
  4.                 gen byte hgc`i'_`e' = (hgc`i' == `e') ;
  5.                 };
  6.         summ hgc`i' hgc`i'_* ;
  7.         *table year children [aw=wtsuppW], c(mean hgc`i') ;
.         *table year children [aw=wtsuppW], c(mean hgc`i'_11) ;
.         };

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
        hgcH |  1,268,498    13.27071    2.059592         11         17
     hgcH_11 |  1,268,498     .172437      .37776          0          1
     hgcH_12 |  1,268,498    .3313706    .4707062          0          1
     hgcH_13 |  1,268,498    .2183102    .4130992          0          1
     hgcH_16 |  1,268,498    .1645765    .3707981          0          1
-------------+---------------------------------------------------------
     hgcH_17 |  1,268,498    .1133057    .3169662          0          1

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
        hgcW |  1,268,498     13.1253    1.912917         11         17
     hgcW_11 |  1,268,498    .1492135    .3562989          0          1
     hgcW_12 |  1,268,498      .37385    .4838247          0          1
     hgcW_13 |  1,268,498    .2370355    .4252644          0          1
     hgcW_16 |  1,268,498    .1620247    .3684736          0          1
-------------+---------------------------------------------------------
     hgcW_17 |  1,268,498    .0778764     .267977          0          1

. foreach i in H W {;
  2.         gen byte white`i' = race`i' == 100 ;
  3.         gen byte hispanic`i' = hispan`i'!=0 ;
  4.         *tabstat white`i' hispanic`i' [aw=wtsuppW], by(year) s(mean) c(v) ;
.         };

. foreach c of numlist 0(1)3 {;
  2.         gen cI`c' = qualChild == `c' ;
  3.         };

. replace cI3 = 1 if qualChild > 3 ;
(48,208 real changes made)

. summ cI* ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
         cI0 |  1,268,498     .459929    .4983919          0          1
         cI1 |  1,268,498    .1932246    .3948278          0          1
         cI2 |  1,268,498    .2185435    .4132582          0          1
         cI3 |  1,268,498    .1283029    .3344269          0          1

. save marriedCouples, replace ;
(note: file marriedCouples.dta not found)
file marriedCouples.dta saved

. */
> *;
. disp "`beginTime'" ;
DateTime: 16 Apr 2018 13:39:29

. disp "DateTime: $S_DATE $S_TIME";
DateTime: 16 Apr 2018 13:40:26

. log close ;
      name:  <unnamed>
       log:  10_MarriedCouples_regPrep.log
  log type:  text
 closed on:  16 Apr 2018, 13:40:26
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
